package cdu.javaendwork.service.Impl.AdoptionMore;

import cdu.javaendwork.dao.Universal;
import cdu.javaendwork.dao.impl.UniversalImpl;
import cdu.javaendwork.model.sqlModel.Collect;
import cdu.javaendwork.service.Interface.AdoptionMore.CollectService;

import java.util.List;

public class CollectServiceImpl implements CollectService {

    Universal universal = new UniversalImpl();

    @Override
    public boolean insert(int userid, int postid) {
        return universal.insert("Collect",userid,postid)==1;
    }

    @Override
    public boolean delete(int userid,int postid) {
        String sql="userid="+userid+" and postid="+postid;
        List<Collect> list=universal.filter("Collect",sql);
        int id=list.get(0).getId();
        return universal.deleteById("Collect",id)==1;
    }

    @Override
    public List<Collect> findByUseridAndPostid(int userid, int postid) {
        return universal.filter("Collect","userid="+userid+" and "+"postid="+postid);
    }

    @Override
    public List<Collect> filterByUserIdLimit(int userid, int pageIndex, int pageSize) {

        return universal.filterLimit("Collect","userid="+userid,pageIndex,pageSize);
    }
}
